package com.leozhang.app;

import com.spire.xls.*;

// 设置单元格格式
public class FormatExcel {
    public static void main(String[] args) {
        Workbook workbook = new Workbook();
        Worksheet sheet = workbook.getWorksheets().get(0);

        // 设置字体
        CellRange range = sheet.getCellRange("A1");
        range.setText("Bold Text");
        range.getStyle().getFont().isBold(true);

        // 设置背景颜色
        // range.getStyle().setColor(Color.YELLOW);

        // 设置数字格式
        sheet.getCellRange("B1").setNumberValue(12345.6789);
        sheet.getCellRange("B1").getStyle().setNumberFormat("0.00");

        workbook.saveToFile("Formatted.xlsx", ExcelVersion.Version2016);
    }
}
